#pragma once

#include "QSPrerequisites.h"
#include <boost/function.hpp>
#include <boost/bind.hpp>

namespace QS
{	
	typedef std::vector<String> CommandArgs;
	typedef boost::function<void (const CommandArgs&)> CommandCallback;

	class Command
	{
	public:
		Command(const String& name, CommandCallback callback)
		{
			init(name, callback);
		}
		
		template<class T, class P>
		Command(const String& name, const T& memberFunc, const P& instance)
		{
			init(name, boost::bind(memberFunc, instance, _1));
		}

		void call(const CommandArgs& args) { mCallback(args); }
		String getName() const{ return mName; }
	private:
		void init(const String& name, CommandCallback callback)
		{
			mCallback = callback;
			mName = name;
		}

		CommandCallback mCallback;
		String mName;
	};
}